package maxssina.view;

import maxssina.activity.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

public class Listview_header {
	public static int REFRESHING = 1;
	public static int REFRESHED = 2;
	private View mView;
	private TextView mTextView;
	private View mProgressBar;
	private int mStatus = 2;

	public Listview_header(Context context) {
		LayoutInflater inflater = LayoutInflater.from(context);
		mView = inflater.inflate(R.layout.listview_header, null);
		initView();
	}

	public Listview_header(Context context, int type) {
		LayoutInflater inflater = LayoutInflater.from(context);
		mView = inflater.inflate(R.layout.listview_header, null);
		initView();
		setViewStatus(type);
	}

	private void initView() {
		mTextView = (TextView) mView.findViewById(android.R.id.text1);
		mProgressBar = mView.findViewById(android.R.id.progress);
	}

	public void setViewStatus(int type) {
		mStatus = type;
		if (type == REFRESHING)
			refeshing();
		else if (type == REFRESHED)
			refeshed();
	}
	public int getViewStatus()
	{
		return mStatus;
	}

	public View getView() {
		return mView;
	}
//	public void setOnClickListenr(View.OnClickListener listner)
//	{
//		mView.setOnClickListener(listner);
//		mTextView.setOnClickListener(listner);
//	}

	private void refeshing() {
		mTextView.setVisibility(View.GONE);
		mProgressBar.setVisibility(View.VISIBLE);
	}

	private void refeshed() {
		mTextView.setVisibility(View.VISIBLE);
		mProgressBar.setVisibility(View.GONE);
	}
}
